package com.xbongbong.pro.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

/**
 * 支持快速编辑的字段
 * @author 吴峰
 * @version v1.0
 * @date 2019/6/17 10:37
 * @since v1.0
 */
@Getter
public enum QuickEditFieldEnum {
    // 单行文本
    TEXT(FieldTypeEnum.TEXT),
    //数字
    NUM(FieldTypeEnum.NUM),
    // 下拉框:combo
    COMBO(FieldTypeEnum.COMBO),
    // DateTimeEnum
    DATETIME(FieldTypeEnum.DATETIME),
    // 多行文本
    TEXTAREA(FieldTypeEnum.TEXTAREA),
    // 复选框组：checkboxgroup
    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),
    // radiogroup 单选按钮
    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),
    // 下拉框复选：combocheck
    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),
    // 超链接
    HREF(FieldTypeEnum.HREF),
    ;
    private FieldTypeEnum fieldTypeEnum;

    QuickEditFieldEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }

    public static QuickEditFieldEnum getByType(Integer type) {
        for (QuickEditFieldEnum quickEditFieldEnum: values()) {
            if (quickEditFieldEnum.getFieldTypeEnum().getType().equals(type)) {
                return quickEditFieldEnum;
            }
        }
        return null;
    }
}
